<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<style>
  #div1 {
    width: 200px;
    height: 200px;
    background: red;
  }
</style>

<body>

  <input type="button" value="变宽" onclick="toWidth(400)" />
  <input type="button" value="变高" onclick="toHeight(400)" />
  <input type="button" value="变黑" onclick="toColor('black')" />

  <div id="div1"></div>


  <script>
    function toColor(color) {
      let div1 = document.getElementById("div1")
      div1.style.background = color
    }

    function toWidth(size) {
      let div1 = document.getElementById("div1")
      div1.style.width = size + "px"
    }
    function toHeight(size) {
      let div1 = document.getElementById("div1")
      div1.style.height = size + "px"
    }

    function setStyle(name,value){
      let div1 = document.getElementById("div1")
      div1.style[name] = value
    }

  </script>

</body>

</html>